extends "AzurItem.gd"

var dmg = 0
var cd = 10
func setItemType():
	itemType = sys.ItemType.TORPEDO

func _connect():
	._connect()
	if masCha.id == "merchant":return
	yield(sys.get_tree().create_timer(0.15), "timeout")
	if not masCha.torpFlag and masCha.mainName.find("史诗") > -1:
		delFromCha()
		return	
	if masCha.torpId == id and masCha.torpName.find("史诗") == -1 or upgraded:
		dmg += int(dmg * 0.4)
		name = name.replace("[普通]", "[史诗]")
	if skPool == null:
		init()
		yield(sys.get_tree().create_timer(0.3), "timeout")

	if masCha.torpSk != null:
		masCha.torpSk.remove()
	masCha.torpName = name
	masCha.torpDmg = dmg
	masCha.torpTxt = info

	masCha.torpSk = call("learnSkill")
	masCha.torpCd = cd
	masCha.torpId = id

	var sk = masCha.getSkill("torpedo")
	if sk != null:
		sk.cd = cd

	delSelf()

func manualAdd(masCha):
	self.masCha = masCha
	if not masCha.torpFlag:
		delFromCha()
		return
	if masCha.torpSk != null:
		masCha.torpSk.remove()
	initVars()
	delayInit()
	masCha.torpName = name
	masCha.torpDmg = dmg
	masCha.torpTxt = info
	masCha.torpSk = call("learnSkill")
	masCha.torpCd = cd
	masCha.torpId = id
	var sk = masCha.getSkill("torpedo")
	if sk != null:
		sk.cd = cd
	del()	
